package com.lishe.lishe.lishe.module.excitation.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lishe.lishe.R;

import java.util.List;

/**
 * Created by shino on 2017/12/25.
 */

public class StringAdapter extends BaseAdapter {
    List<String> list;

    public StringAdapter(List<String> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if (convertView == null) {
            convertView = View.inflate(parent.getContext(), R.layout.item_center_textview, null);
            holder = new Holder();
            holder.textView = convertView.findViewById(R.id.text);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.textView.setText(list.get(position));
        return convertView;
    }

    class Holder {
        TextView textView;
    }
}
